import {
  getSeriesList,
} from '@/api/process/mesProcessMaterial'

export const seriesDialog = {
  data() {
    return {
      seriesDialogVisible: false,  // 系列弹框隐藏显示
      getSeriesList,  // 获取弹框数据接口
      seriesSearchConfig: {
        inline: true,
        formDesc: {
          seriesCode: {
            type: 'input',
            layout: 8,
            label: $i18n.t('mesProcessMaterial.seriesCoding')
          },
          seriesName: {
            type: 'input',
            layout: 8,
            label: $i18n.t('mesProcessMaterial.seriesName')
          }
        },
      },
      seriesColumn: [
        {
          type: 'selection'
        },
        {
          type: 'index',
          label: $i18n.t('common.order'),
          width: 60
        },
        {
          prop: 'seriesCode',
          label: $i18n.t('mesProcessMaterial.seriesCoding'),
          width: 120,
          showOverflowTooltip: true
        },
        {
          prop: 'seriesName',
          label: $i18n.t('mesProcessMaterial.seriesName'),
          width: 150,
          showOverflowTooltip: true
        },
      ],
      seriesDialogFooter: [  // 系列查询dialog底部按钮
        {
          name: $i18n.t("common.cancel"),
        },
        {
          name: $i18n.t("common.ok"),
          type: 'primary',
          disabled: (data) => {
            return data.length !== 1;
          }
        },
      ],
    }
  },
  methods: {
    // 弹框表格，双击表格，或者点击确定 返回选中数据
    getSelectedSeries(data) {
      this.$set(this.formDataDialog, 'seriesName', data[0]['seriesName']);
      this.$set(this.formDataDialog, 'seriesCode', data[0]['seriesCode']);
    },
    // 系列查询dialog底部取消和确定按钮事件
    changeSeriesDialog(data) {
      data.name === $i18n.t('common.ok') && this.getSelectedSeries(data.rows);
      this.seriesDialogVisible = false;
    },
  }
}
